package com.srwl.mytx.domain;

import android.os.Parcel;
import android.os.Parcelable;

import com.srwl.mytx.domain.User;

import java.util.Date;

public class Donation implements Parcelable {
    private String id;

    private String mId;//捐赠者用户id

    private String tId;//受捐用户id,最终受款人id

    private String fId;//该笔捐赠对应的转赠id,在转赠之前，该值为空

    private String oId;//organization_id受款主体id ，捐款最终是走向个人；一项捐给某主体的捐款，一开始tId是空的，由该主体管理员决定捐款去向（或者由管理员发起投票决定），避免管理员把钱放自己兜里面，应该设置举报途径，

    private Double amount;

    private Integer praiseSize;

    private Integer type;

    private Integer status;

    private String extra;

    private Date updated;

    private Date created;

    private User targetUser; //目标用户信息，如果查询发出的捐赠，那这是受赠者用户信息，如果是查询 收到的捐赠，那么这个是 捐赠者信息

    private Topic attachTopic; // 此捐赠依附的主题（主体）

    private Boolean hasPraise;

    public Donation(String id, String mId, String tId, String oId, Double amount, Integer type, Integer status, String extra, Date updated, Date created) {
        this.id = id;
        this.mId = mId;
        this.tId = tId;
        this.oId = oId;
        this.amount = amount;
        this.type = type;
        this.status = status;
        this.extra = extra;
        this.updated = updated;
        this.created = created;
    }

    public Donation() {
        super();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public String getmId() {
        return mId;
    }

    public void setmId(String mId) {
        this.mId = mId == null ? null : mId.trim();
    }

    public String gettId() {
        return tId;
    }

    public void settId(String tId) {
        this.tId = tId == null ? null : tId.trim();
    }

    public String getfId() {
        return fId;
    }

    public void setfId(String fId) {
        this.fId = fId;
    }

    public String getoId() {
        return oId;
    }

    public void setoId(String oId) {
        this.oId = oId == null ? null : oId.trim();
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public Integer getPraiseSize() {
        return praiseSize;
    }

    public void setPraiseSize(Integer praiseSize) {
        this.praiseSize = praiseSize;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra == null ? null : extra.trim();
    }

    public Date getUpdated() {
        return updated;
    }

    public void setUpdated(Date updated) {
        this.updated = updated;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public User getTargetUser() {
        return targetUser;
    }

    public void setTargetUser(User targetUser) {
        this.targetUser = targetUser;
    }

    public Topic getAttachTopic() {
        return attachTopic;
    }

    public void setAttachTopic(Topic attachTopic) {
        this.attachTopic = attachTopic;
    }

    public Boolean getHasPraise() {
        return hasPraise;
    }

    public void setHasPraise(Boolean hasPraise) {
        this.hasPraise = hasPraise;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.id);
        dest.writeString(this.mId);
        dest.writeString(this.tId);
        dest.writeString(this.oId);
        dest.writeValue(this.amount);
        dest.writeValue(this.type);
        dest.writeValue(this.status);
        dest.writeString(this.extra);
        dest.writeLong(this.updated != null ? this.updated.getTime() : -1);
        dest.writeLong(this.created != null ? this.created.getTime() : -1);
        dest.writeParcelable(this.targetUser, flags);
        dest.writeParcelable(this.attachTopic, flags);
    }

    protected Donation(Parcel in) {
        this.id = in.readString();
        this.mId = in.readString();
        this.tId = in.readString();
        this.oId = in.readString();
        this.amount = (Double) in.readValue(Double.class.getClassLoader());
        this.type = (Integer) in.readValue(Integer.class.getClassLoader());
        this.status = (Integer) in.readValue(Integer.class.getClassLoader());
        this.extra = in.readString();
        long tmpUpdated = in.readLong();
        this.updated = tmpUpdated == -1 ? null : new Date(tmpUpdated);
        long tmpCreated = in.readLong();
        this.created = tmpCreated == -1 ? null : new Date(tmpCreated);
        this.targetUser = in.readParcelable(User.class.getClassLoader());
        this.attachTopic = in.readParcelable(Topic.class.getClassLoader());
    }

    public static final Creator<Donation> CREATOR = new Creator<Donation>() {
        @Override
        public Donation createFromParcel(Parcel source) {
            return new Donation(source);
        }

        @Override
        public Donation[] newArray(int size) {
            return new Donation[size];
        }
    };

    @Override
    public String toString() {
        return "Donation{" +
                "id='" + id + '\'' +
                ", mId='" + mId + '\'' +
                ", tId='" + tId + '\'' +
                ", fId='" + fId + '\'' +
                ", oId='" + oId + '\'' +
                ", amount=" + amount +
                ", praiseSize=" + praiseSize +
                ", type=" + type +
                ", status=" + status +
                ", extra='" + extra + '\'' +
                ", updated=" + updated +
                ", created=" + created +
                ", targetUser=" + targetUser +
                ", attachTopic=" + attachTopic +
                ", hasPraise=" + hasPraise +
                '}';
    }
}